package com.enjoyor.soa.traffic.rest.efoms.dubbo.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.dto.efoms.WorkordersInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboWorkordersInfoService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IWorkordersInfoConsumeService;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Component
public class WorkordersInfoConsumeService implements IWorkordersInfoConsumeService {

	@Reference(version = "1.0.0", timeout = 10000) 
	//@Reference(version = "1.0.0", timeout = 10000, url="dubbo://192.168.56.8:21141")
	//@Reference(version = "1.0.0", timeout = 10000, url="dubbo://192.168.20.77:21141")
	private IDubboWorkordersInfoService dubboWorkordersInfoService;
	
	@Override
	public ResultPojo selectWorkordersInfoById(String workordersId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.selectWorkordersInfoById(workordersId);
		} catch (Exception e) {
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}

	@Override
	public ResultPojo selectWorkordersInfoList(String workordersId, String repStartDate, String repEndDate,
			String devCategoryCode, String devTypeCode, String devId, String devName, String key, String devAreaCode,
			String devDeptId, String failureTypeCode, String failureDescrible, String repSourceCode,
			String workordersStatusCode, String lableClick) {
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.selectWorkordersInfoList(workordersId, repStartDate, repEndDate,
					devCategoryCode, devTypeCode, devId, devName, key, devAreaCode, devDeptId, failureTypeCode,
					failureDescrible, repSourceCode, workordersStatusCode, lableClick);
		} catch (Exception e) {
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}

	@Override
	public ResultPojo selectWorkordersInfoPage(Page page, String workordersId, String repStartDate, String repEndDate,
			String devCategoryCode, String devTypeCode, String devId, String devName, String key, String devAreaCode,
			String devDeptId, String failureTypeCode, String failureDescrible, String repSourceCode,
			String workordersStatusCode, String orderSeq, String orderMode, String lableClick, List<String> noStatusCodeList) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.selectWorkordersInfoPage(page, workordersId, repStartDate,
					repEndDate, devCategoryCode, devTypeCode, devId, devName, key, devAreaCode, devDeptId,
					failureTypeCode, failureDescrible, repSourceCode, workordersStatusCode, orderSeq, orderMode, 
					lableClick, noStatusCodeList);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}

	@Override
	public ResultPojo insertWorkordersInfo(WorkordersInfoDto workordersInfoDto, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.insertWorkordersInfo(workordersInfoDto, personName);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultHelper.getResult(EnumAppCode.NULL_POINTER);
		}
		return resultPojo;
	}

	@Override
	public ResultPojo updateWorkordersInfo(WorkordersInfoDto workordersInfoDto, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.updateWorkordersInfo(workordersInfoDto, personName);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}

	@Override
	public ResultPojo deleteWorkordersInfo(String workordersId, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.deleteWorkordersInfo(workordersId, personName);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}
	
	@Override
	public ResultPojo selectOperationCount(String startTime, String endTime) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		try {
			resultPojo = dubboWorkordersInfoService.getOperationCount(startTime, endTime);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultHelper.getResult(e);
		}
		return resultPojo;
	}
}
